//
//  HBReadBottomView.m
//  HeartBeat
//
//  Created by karong on 2023/9/12.
//

#import "HBReadBottomView.h"
#import "HBReadSettingManager.h"
#import "UIButton+ImageAlign.h"
@interface HBReadBottomView ()
@property (nonatomic, strong) HBChapterModel * model;
@property (weak, nonatomic) IBOutlet UIButton *nightBtn;
@property (strong, nonatomic) IBOutletCollection(UIButton) NSArray *btnArray;
@end

@implementation HBReadBottomView

- (void)awakeFromNib {
    [super awakeFromNib];
    for (UIButton * btn in self.btnArray) {
        [btn setButtonImageTitleStyle:(WSButtonImageTitleStyleTop) padding:9];
    }
}

- (void)setContentDataWithShowModel:(HBChapterModel *)showModel {
    self.model = showModel;
    self.sliderView.minimumValue = 0;
    self.sliderView.maximumValue = showModel.pageCount - 1;
}

- (void)reloadAllData {
    if (![[HBReadSettingManager shared] showModel].night) {
        [self.nightBtn setTitle:WSLocalized(@"夜間") forState:(UIControlStateNormal)];
        [self.nightBtn setImage:IMG(@"icon_b_yj_w") forState:(UIControlStateNormal)];
    }
    else {
        [self.nightBtn setTitle:WSLocalized(@"白天") forState:(UIControlStateNormal)];
        [self.nightBtn setImage:IMG(@"icon_daytime_w") forState:(UIControlStateNormal)];
    }
}
- (IBAction)lastAction:(id)sender {
    if ([self.delegate respondsToSelector:@selector(bottomClickLastNext:hasLast:)]) {
        [self.delegate bottomClickLastNext:self hasLast:YES];
    }
}
- (IBAction)nextAction:(id)sender {
    if ([self.delegate respondsToSelector:@selector(bottomClickLastNext:hasLast:)]) {
        [self.delegate bottomClickLastNext:self hasLast:NO];
    }
}
- (IBAction)sliderValueChange:(UISlider *)sender {
    if ([self.delegate respondsToSelector:@selector(bottomSliderPageChange:pageControl:)]) {
        [self.delegate bottomSliderPageChange:self pageControl:sender.value];
    }
}
- (IBAction)目錄Action:(id)sender {
    if ([self.delegate respondsToSelector:@selector(bottomChapterList:)]) {
        [self.delegate bottomChapterList:self];
    }
}
- (IBAction)白天Action:(id)sender {
    if ([self.delegate respondsToSelector:@selector(bottomChangeDayNight:ifDay:)]) {
        [self.delegate bottomChangeDayNight:self ifDay:![[HBReadSettingManager shared] showModel].night];
    }
}
- (IBAction)設置Action:(id)sender {
    if ([self.delegate respondsToSelector:@selector(bottomClickSeeting:)]) {
        [self.delegate bottomClickSeeting:self];
    }
}


@end
